//
//  RW_UserSingleRenameView.m
//  SleepApp
//
//  Created by chuangqi on 2021/4/9.
//  Copyright © 2021 RiceWang. All rights reserved.
//

#import "RW_UserSingleRenameView.h"
#import "RW_UserSingleItemViewCell.h"
#import "RW_UserSingleListItemCell.h"
#import "RW_UserSingleModel.h"
@interface RW_UserSingleRenameView(){
    /** 用户歌单 */
    RW_UserSingleItemViewCellModel *_user_single_model;
    /** 用户歌单歌曲 */
    RW_UserSingleListItemCellModel *_user_single_song_model;
}

@end
@implementation RW_UserSingleRenameView

/** 初始化视图数据 */
-(void)initData:(NSArray *)dataList{
    self.wlclass_title_label.text = @"歌单重命名";
    NSLog(@"%@",dataList);
    for (id data in dataList) {
        if ([data isKindOfClass:RW_UserSingleItemViewCellModel.class]){
            _user_single_model = data;
            break;
        } else if ([data isKindOfClass:RW_UserSingleListItemCellModel.class]){
            _user_single_song_model = data;
            break;
        }
    }
    if (_user_single_model){
        self.wlclass_text_field.text = _user_single_model.title_string;
    } else if (_user_single_song_model){
        self.wlclass_text_field.text = _user_single_song_model.title_string;
    }
}
#pragma mark -- Base代理
/**
 可选
 是否需要处理点击确定后的操作逻辑
 点击确认按钮的 选中数据操作。
 需要子试图调用 defaultSureCloseViewData: 方法
 会回调 closeBlock_wl 的block块，内容为操作完毕后的内容
 默认回调 closeBlock_wl，无参数
 */
-(void)clickSelectCloseViewData:(id)data sureBlock:(void(^)(id data))sureBlock{
    NSString *titleString = data;
    [SVProgressHUD showMask_wl];
    if (_user_single_model){
        [[[RW_UserSingleModel updataUserSingleId:_user_single_model.user_single_model.xid name:titleString] then:^id _Nullable(NSString * _Nullable value) {
            [SVProgressHUD dismiss_wl];
            sureBlock(titleString);
            return nil;
        }] catch:^(NSError * _Nonnull error) {
            [SVProgressHUD showError_wl:error.domain];
        }];
    } else if (_user_single_song_model){

    }
}
@end
